package cn.hackcloud.javabase.juc;

import org.jibx.binding.Run;

import java.util.concurrent.CountDownLatch;

/**
 * 
 * @author hackcloud
 *
 */
public class TestCountDownLatch {
	public static void main(String[] args) throws Exception {
		System.out.println(Runtime.getRuntime().availableProcessors());
	}
}

class LatchDemo implements Runnable {
	private CountDownLatch latch;

	public LatchDemo(CountDownLatch latch) {
		this.latch = latch;
	}

	@Override
	public void run() {
		try {
			for (int i = 0; i < 50000; i++) {
				if (i % 2 == 0) {
					System.out.println(i);
				}
			}
		} finally {
			latch.countDown();
		}
	}

}
